﻿using BCL.BaseLib;
using BCL.BaseLib.Basics;
using BCL.Tool.Extend;
using BCL.WPFComponent.Base;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;

namespace WpfControlTool.Windows
{
    /// <summary>
    /// UCTopControl.xaml 的交互逻辑
    /// </summary>
    public partial class UCTopControl : BaseFunctionControl
    {
        public UCTopControl()
        {
            InitializeComponent();
        }

        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            if (BCLApplication.AppFunMunes == null)
                return;
            textName.Text = DevicesView.Logic.App.AppResource.CurrentResource.LoginUser.UserName;
            foreach (var item in BCLApplication.AppFunMunes)
            {
                if (item.ItemType == FunctionItemType.Item && item.IsCreate)
                {
                    Border bd = new Border { Width = 20, Height = 20, Margin = new Thickness(0, 0, 10, 0), Tag = item };

                    bd.Style = (Style)FindResource("BorderStyle");

                    bd.Child = new Image { Stretch = Stretch.Fill, Width = 20, Height = 20, Source = item.Image.ToBitmap() };

                    bd.MouseDown += (st, e1) => BCLApplication.MainForm.OpenFunction(item);
                    PanelBarItem.Children.Add(bd);
                }
            }
        }

        public override void LanguageBinding()
        {
            throw new System.NotImplementedException();
        }

        public override void ReloadData(object data)
        {
            base.ReloadData(data);
        }

        private void StackPanel_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            new Controls.UCUserInfo().ShowDialog(null);
        }
    }
}
